//
// Created by wopy on 2020/9/1.
//
#include "bihua.hpp"
#include "InputWord.hpp"
#include "Input.hpp"

using namespace std;

FCITX_DEFINE_PLUGIN (fcitx_bh, ime, FcitxIMClass) = {
        imCreate,
        imDestroy
};

void *imCreate(struct _FcitxInstance *instance) {
    InputState *inputState = new InputState(instance);
    FcitxInstanceRegisterIM(
            instance,
            inputState,
            "bihua",
            "笔画",
            "bihua",
            imInit,
            nullptr,
            doInput,
            doGetWordList,
            nullptr,
            nullptr,
            nullptr,
            nullptr,
            100,
            "zh_CN"
    );

    return inputState;
}

boolean imInit(void *arg) {
    InputState *inputState = (InputState *) arg;
    FcitxInstance *instance = inputState->getInstance();
    FcitxInstanceSetContext(instance, CONTEXT_IM_KEYBOARD_LAYOUT, "us"); //键盘布局
    boolean flag = true;
    FcitxInstanceSetContext(instance, CONTEXT_SHOW_REMIND_STATUS, &flag);  //开启联想
    return true;
}

void imDestroy(void *arg) {
    delete (InputState *) arg;
}
